﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using sexhealth.console.service.post;
using sexhealth.console.service.post.vo;

public partial class admin_UC01_0102copyright : System.Web.UI.Page
{
    PostService postService = new PostService();
    //版權聲明channel id
    int channelId = 2;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ShowContent();
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        IList<PostVO> postList = postService.GetPostList(channelId);
        if (postList.Count > 0)
        {
            postList[0].HtmlContent = ckbContent.value;
            postList[0].Title = "版權聲明與使用規定";
            postService.UpdatePost(postList[0]);
        }
        else
        {
            PostVO post = new PostVO();
            post.HtmlContent = ckbContent.value;
            post.Title = "版權聲明與使用規定";
            post.BelongToChannelId = channelId;
            postService.InsertPost(post);
        }
        ShowContent();
    }
    private void ShowContent()
    {
        IList<PostVO> postList = postService.GetPostList(channelId);
        if (postList.Count > 0)
        {
            ckbContent.value = postList[0].HtmlContent;
        }

    }
}
